home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / irix / scripts / ddir < prev    next >
Encoding:
Text File  |  1994-08-02  |  1.3 KB  |  67 lines

  1. #!/bin/csh -f
  2. #
  3. # $Id: ddir,v 1.2 93/11/17 14:24:19 carlson Exp $
  4. #
  5. # Description:
  6. #    This script will scan a directory and just list those files
  7. #    that are directories.
  8. #
  9. # Revision History:
  10. #    $Log:    ddir,v $
  11. # Revision 1.2  93/11/17  14:24:19  carlson
  12. # Modified to make sure there is a strlen in the path before checking
  13. #   to see if it is executable.
  14. # Revision 1.1  93/08/20  13:18:38  carlson
  15. # Initial revision
  16. # Revision 1.1  1993/02/24  14:12:42  chris
  17. # Initial revision
  18. #
  19. #
  20. #-----------------------------------------------------------------------
  21.  
  22. set x = ( `which strlen` )
  23. if ( $#x > 1 || ! -e $x ) then
  24.     echo "This script requires the program 'strlen' to run."
  25.     exit
  26. endif
  27.  
  28. set list = ()
  29. set i = 0
  30. foreach file ( * )
  31.     if ( -d $file ) then
  32.     set list = ( $list $file )
  33.     set a = `strlen $file`
  34.     if ( $a > $i ) set i = $a
  35.     endif
  36. end
  37.  
  38. if ( $i == 0 ) exit
  39.  
  40. #----
  41. # i        = Maximum size of word
  42. # columns    = Number of possible columns
  43. # rows        = Number of rows necessary
  44. #
  45.  
  46. @ i = $i + 2
  47. @ columns = 80 / $i
  48. @ rows    = ( $#list / $columns ) + 1
  49. set format = "%-${i}.${i}s"
  50.  
  51. @ row     = 0
  52.  
  53. while ( $rows > $row )
  54.     @ column = 0
  55.     while ( $columns > $column )
  56.     @ element = ( $row * $columns ) + $column + 1
  57.     if ( $element <= $#list ) then
  58.         printf "$format" $list[$element]/
  59.     endif
  60.     @ column = $column + 1
  61.     end
  62.     echo ""
  63.     @ row = $row + 1
  64. end
  65.